package com.travelms.service.commonuserpage;

import com.travelms.dao.DBFind;
import com.travelms.util.DataEffect;

import java.io.IOException;
import java.sql.SQLException;
import java.util.Scanner;

public class userRecharge {
    DBFind dbFind = new DBFind();
    Scanner sc = new Scanner(System.in);
    public userRecharge(String username) throws SQLException, IOException {
        String money = null;
        while (true) {
            System.out.println("请输入你要充值的金额");
            money = sc.nextLine();
            if (DataEffect.isNumber(money)){
                break;
            }else {
                System.out.println("输入错误");
            }
        }

        if (dbFind.userRecharge(username,money)){
            System.out.println("充值成功");
            System.out.println("按任意键退出");
            String n = sc.nextLine();
        }else {
            System.out.println("充值失败");
            System.out.println("按任意键退出");
            String n = sc.nextLine();
        }

    }
}
